<template>
  <div id="remind">
    <div
      v-show="stylesRemind.status != 0"
      @click="getGroup(-4,'remind')"
      class="remind"
      :class="[currentId==-4?'remind-choose':'']"
      :style="{top:stylesRemind.shifting+'px'}"
    >
      <div
        class="remind-bg"
        :style="{background:stylesRemind.colorBg,opacity:stylesRemind.percent/100}"
      ></div>
      <div class="remind-content">
        <el-carousel indicator-position="none" height="40px" direction="vertical" :autoplay="true">
          <el-carousel-item v-for="(v,i) in stylesRemind.numberList" :key="i">
            <div class="r-in">
              <div>
                <img
                  style="width: 24px; height: 24px;border-radius:50%"
                  :src="v.img==''?circleUrl:v.img"
                  alt
                />
                <span style="width:60%">{{v.text==''?'最新订单来自XXX用户':v.text}}</span>
              </div>
              <span>{{v.time==''?'5秒':v.time+'秒'}}</span>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
      <div class="single-remind">
        <el-popover v-show="currentId==-4" placement="left" width="200" v-model="visible">
          <p>确定删除此组件吗？</p>
          <div style="text-align: right; margin: 10px 0 0">
            <el-button plain size="mini" @click="visible = false">取消</el-button>
            <el-button type="primary" size="mini"  @click.stop="deleteSingle(-4)">确定</el-button>
          </div>
          <el-button type="danger" size="mini" slot="reference">删除</el-button>
        </el-popover>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "remind",
  data() {
    return {
      visible:false,
      circleUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
    };
  },
  computed: {
    ...mapState(["remind", "currentId", "currentName", "list"]),
    stylesRemind() {
      return this.remind[0].styles;
    },
  },
  props: ["num"],
  created() {},
  methods: {
    ...mapMutations(["getList", "getCurrenChoose", "getCurrenChooseName"]),
    deleteSingle(num) {
      this.stylesRemind.status = 0;
      this.visible = false
      if (this.list.length != 0) {
        this.getCurrenChoose(0);
        this.getCurrenChooseName(this.list[0].name + "Change");
      } else {
        this.getCurrenChoose(0);
        this.getCurrenChooseName(" ");
      }
    },
    getGroup(i, name) {
      this.getCurrenChoose(i);
      this.getCurrenChooseName(name + "Change");
    },
  },
};
</script>

<style lang="less" scoped>
@import url("../../../assets/css/base.less");
.remind-choose {
  border: 1px solid @mainColor !important;
}
.remind {
  position: absolute;
  left: 10px;
  top: 120px;
  width: 70%;
  height: 40px;
  z-index: 999;
  border: 1px solid rgba(0,0,0,0);
  > .remind-bg {
    background-color: #000;
    width: 100%;
    height: 100%;
    opacity: 0.8;
    border-radius: 10px;
  }
  > .remind-content {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    color: #fff;
    height: 40px;
    padding: 0 5px;
    .r-in {
      display: flex;
      justify-content: space-between;
      align-items: center;
      > div:nth-of-type(1) {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        height: 37px;
        width: 75%;
        > span {
          font-size: 12px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          margin-left: 5px;
        }
      }
    }
  }
  > .single-remind {
    position: absolute;
    right: -65px;
    top: 0;
  }
}
</style>
